﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.MessageMutator;

namespace Authentication
{
    public class OutgoingAccessPropogator : IMutateOutgoingTransportMessages, INeedInitialization
    {

        public void MutateOutgoing(NServiceBus.Unicast.Messages.LogicalMessage logicalMessage, TransportMessage transportMessage)
        {
            transportMessage.Headers["access_token"] = "authentic_user";
        }

        public void Customize(BusConfiguration configuration)
        {
            configuration.RegisterComponents(c => c.ConfigureComponent<OutgoingAccessPropogator>(DependencyLifecycle.SingleInstance));
        }
    }
}
